package edu.mit.media.fv.aqview
{
	import edu.mit.media.fv.aqwidgets.*;
	import edu.mit.media.fv.blocks.*;
	import edu.mit.media.fv.components.*;
	import edu.mit.media.fv.events.*;
	import edu.mit.media.fv.fluidspace.*;
	
	import flash.display.*;
	import flash.events.MouseEvent;
	import flash.text.*;
	
	public class AQPixBuilder extends AQViewer
	{
		//var tags:AQTextField;
		var painter:AQPainter;
		//var sendButton:DisplayObject;
		
		public function AQPixBuilder()
		{
			super();
			this.painter = new AQPainter(25,150,600,225);
			this.addChild(this.painter);
			this.sendButton.addEventListener(MouseEvent.CLICK, sendMessage);
			
			FluidEventHandler.addEventListener(WidgetEvent.DISPLAY_PIX_BUILDER, displayWidget);
		}
		public function displayWidget(event:WidgetEvent = null):void{
			FluidEventHandler.dispatchEvent(new WidgetEvent(WidgetEvent.DISPLAY_WIDGET, this, "Text"));

			if(event.id == -1){
				this.tags.text = "";
				this.id = event.id;
			}else{
				this.tags.text = "RE: "+event.subject;
				this.id = event.id;
			}
			
		}
		private function sendMessage(event:MouseEvent):void{
			var data:Object = new Object();
			data.command = FluidConstants.REQUEST_SEND_OBJECT;
			data.type = FluidConstants.PIX;
			data.tags = this.tags.text;
			data.id = this.id;
			data.priority = 1;
			data.reply = this.id;
			var fvne:FVNetworkEvent = new FVNetworkEvent(data);
			FluidEventHandler.dispatchEvent(fvne);
			
			FluidEventHandler.dispatchEvent(new WidgetEvent(WidgetEvent.DISPLAY_WORKSPACE));
		}
		
	}
}